package com.lxmes.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.business.domain.CcQualityCheckInfo;
import com.lxmes.business.service.ICcQualityCheckInfoService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 质量检验记录Controller
 * 
 * @author 张志煜
 * @date 2022-11-28
 */
@RestController
@RequestMapping("/business/qualityCheckInfo")
public class CcQualityCheckInfoController extends BaseController
{
    @Autowired
    private ICcQualityCheckInfoService ccQualityCheckInfoService;

    /**
     * 查询质量检验记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:qualityCheckInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcQualityCheckInfo ccQualityCheckInfo)
    {
        startPage();
        List<CcQualityCheckInfo> list = ccQualityCheckInfoService.selectCcQualityCheckInfoList(ccQualityCheckInfo);
        return getDataTable(list);
    }

    /**
     * 导出质量检验记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:qualityCheckInfo:export')")
    @Log(title = "质量检验记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcQualityCheckInfo ccQualityCheckInfo)
    {
        List<CcQualityCheckInfo> list = ccQualityCheckInfoService.selectCcQualityCheckInfoList(ccQualityCheckInfo);
        ExcelUtil<CcQualityCheckInfo> util = new ExcelUtil<CcQualityCheckInfo>(CcQualityCheckInfo.class);
        util.exportExcel(response, list, "质量检验记录数据");
    }

    /**
     * 获取质量检验记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:qualityCheckInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ccQualityCheckInfoService.selectCcQualityCheckInfoById(id));
    }

    /**
     * 新增质量检验记录
     */
    @PreAuthorize("@ss.hasPermi('business:qualityCheckInfo:add')")
    @Log(title = "质量检验记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcQualityCheckInfo ccQualityCheckInfo)
    {
        return toAjax(ccQualityCheckInfoService.insertCcQualityCheckInfo(ccQualityCheckInfo));
    }

    /**
     * 修改质量检验记录
     */
    @PreAuthorize("@ss.hasPermi('business:qualityCheckInfo:edit')")
    @Log(title = "质量检验记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcQualityCheckInfo ccQualityCheckInfo)
    {
        return toAjax(ccQualityCheckInfoService.updateCcQualityCheckInfo(ccQualityCheckInfo));
    }

    /**
     * 删除质量检验记录
     */
    @PreAuthorize("@ss.hasPermi('business:qualityCheckInfo:remove')")
    @Log(title = "质量检验记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccQualityCheckInfoService.deleteCcQualityCheckInfoByIds(ids));
    }
}
